var timer

var clear = function(){
	clearInterval(timer);
}
$(document).ready(function(e) {
    $('#top_index').bind('mouseover',function(){$('#top_index').attr('src','images/top_index_on.jpg');})
				.bind('mouseout',function(){$('#top_index').attr('src','images/top_index.jpg');});
    $('#top_contact').bind('mouseover',function(){$('#top_contact').attr('src','images/top_contact_on.jpg');})
				.bind('mouseout',function(){$('#top_contact').attr('src','images/top_contact.jpg');});
    $('#nav_01').bind('mouseover',function(){$('#nav_01').attr('src','images/nav_01_on.jpg');})
				.bind('mouseout',function(){$('#nav_01').attr('src','images/nav_01.jpg');});
    $('#nav_02').bind('mouseover',function(){$('#nav_02').attr('src','images/nav_02_on.jpg');})
				.bind('mouseout',function(){$('#nav_02').attr('src','images/nav_02.jpg');});
    $('#nav_03').bind('mouseover',function(){$('#nav_03').attr('src','images/nav_03_on.jpg');})
				.bind('mouseout',function(){$('#nav_03').attr('src','images/nav_03.jpg');});
    $('#nav_04').bind('mouseover',function(){$('#nav_04').attr('src','images/nav_04_on.jpg');})
				.bind('mouseout',function(){$('#nav_04').attr('src','images/nav_04.jpg');});
    $('#nav_05').bind('mouseover',function(){$('#nav_05').attr('src','images/nav_05_on.jpg');})
				.bind('mouseout',function(){$('#nav_05').attr('src','images/nav_05.jpg');});
    $('#nav_01_01').bind('mouseover',function(){$('#nav_01_01').attr('src','images/nav_p2_03_selected.jpg');})
				.bind('mouseout',function(){$('#nav_01_01').attr('src','images/nav_p2_03.jpg');});
    $('#nav_01_02').bind('mouseover',function(){$('#nav_01_02').attr('src','images/nav_p2_04_selected.jpg');})
				.bind('mouseout',function(){$('#nav_01_02').attr('src','images/nav_p2_04.jpg');});
    $('#nav_01_03').bind('mouseover',function(){$('#nav_01_03').attr('src','images/nav_p2_05_selected.jpg');})
				.bind('mouseout',function(){$('#nav_01_03').attr('src','images/nav_p2_05.jpg');});
	$('.leftmenu li[class!=selected] a').bind('mouseover',function(){$(this).parent().css('background-color','#aaa');})
				.bind('mouseout',function(){$(this).parent().css('background-color','');});
	$('.return img').bind('click',function(){window.history.go(-1);});
	$('.return img').css('cursor','pointer');
	bind(1);
	bind(2);
	bind(3);
	bind(4);
	autoswitch(1);
});
function bind(index){
	$('#banner'+index).bind('mouseover',function(){
		$('#banner').css('background-image','url(images/banner'+index+'.png)');
		for(var i=1;i<=4;i++){
			$('#banner'+i).attr('src','images/point_05.png');
			bind(i);
		}
		$('#banner'+index).attr('src','images/point_03.png');
		$('#banner'+index).unbind('mouseover');
		autoswitch(index);
	});
}
function autoswitch(current){
	var handler = function(){
		if(current==4)
			current=1;
		else
			current++;
        $('#banner'+current).mouseover();
    }
	clear();
	timer = setInterval( handler , 5000);
}